home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Format CD 40
/
Amiga Format CD40 (1999-05-11)(Future Publishing)(GB)(Track 1 of 3)[!][issue 1999-06].iso
/
-readerstuff-
/
steve_turner
/
canal
/
routes
/
canal.doc
< prev
next >
Wrap
Text File
|
1999-03-29
|
20KB
|
377 lines
****************************************************************************
* CANAL CALCULATOR BY STEVE TURNER (c) 1998 *
****************************************************************************
I use hire canal boats and needed to ensure that I could get to the locations
I desired and return the boat on time. I also wanted to try and stop at
interesting locations for lunch and for the night (i.e. by a pub!). So I sat
down with the appropriate Nicholson guide and tried to work out an
itinerary. If, like me, you have tried that you will know how hard this simple
task is. How far is it? How fast do I travel? How long to do a lock? With a
little experience you soon learn this but it takes ages working out distances
and times. After a couple of hours work you find your half a day short.
What if I start half an hour earlier each morning you think? Oh No! I'm not
working all that out again!
Well as you've already guessed this is the answer to your prayers. I first
wrote this program in 'C' on a 1.3 version Amiga. When I upgraded to
V2.04 it didn't seem to work correctly and whilst the source code was well
documented, finding this bug was almost impossible. In addition, after using
the program a few times I found I wanted a few more facilities. About the
same time I got a cheap version of Blitz Basic. Within days I had registered
for the full version and had decided to rewrite the canal calculator as my
introduction.
By 1998 my increasing dissatisfaction with the user interface was finally
brought to a head when Erwan Fouret introduced his MUI Library for Blitz.
So late into the night over June, July and August I converted 'Canal_Calc'
into an MUI version and dropped the old one. I also took this opportunity to
improve the program and increase it's useability.
Whilst Blitz2 runs very fast the extremely complicated search algorithm is a
bit slow. However, I'm getting ahead of myself. Here is a full description of
the program using the menus as the headings. The menus are described as
they appear and not in the order you would use them. Note therefore that
you need to have a map loaded or created before most of the menu items
can be used. One other point is that the program will not complain if you
load an unmatched map and route but it may get confused. I take no
responsibility for the outcome if you do this.
The search algorithm is recursive and whilst I've given you a large stack you
may run into two problems;
1) If during a search you get a crash increase the stack (see Icon Info file
details)
2) If the program will not load due to lack of memory decrease the stack
size in the same way. Of course you may then get a crash due to the stack
being too small but don't let that stop you trying.
One other trick you may find useful to speed up a search is to;
1) Load the map.
2) Decide your route.
3) Edit the map by deleting every location next to a junction that you will
not be travelling through.
4) Do the route search.
5) Save the route.
6) Reload the correct map.
Hey Presto! You have quickly created a route and still got the map intact.
However, in version 3.0 I have introduced a manual method of installing the
route. I now find this is actually the best way to do it!
PROJECT MENU
============
NEW - (A)N
This is straight forward. As you would expect, any Maps or Routes are
dumped from memory and you are ready to start a new project.
LOAD > MAP - (A)L
Again, no surprises, load a previously saved map. I've included a couple of
maps (maybe more ) on the disk split up as Nicholson guides. They may not
be complete or have the places you need so you'll just have to amend them
or start your own!
LOAD > ROUTE - (A)K
No route has been included on the disk so you need to create one. Then
you can use this menu item to reload it.
LOAD > V1.0 MAP
There will not be many of you need this but it will load maps saved out of
the version one canal calculator. You probably deduced from this the two
map formats are different.
SAVE > MAP - (A)S
Very simple again. Use this to save to any device a map from memory. This
is disabled in none registered version.
SAVE > ROUTE - (A)A
Yes. Save a route from memory to any device. This is disabled in none
registered version.
CALCULATE - (A)C
This is the hart of the program and must be used to create a 'route' before
any useful work can be done. For a route to be calculated a map must exist
in memory. If you use calculation the program will attempt to find the
shortest route between the start and end points you specify. In addition, it
will go via up to 10 locations given. Why have Via locations? Well to allow
you to force the program to follow a certain path. Now you may ask why
have the program to find the shortest route and then force it to go another
way? The answer to that is that you may want to go round a ring in a
certain direction. Alternatively, you may want to take the longest route or
detour up a branch. In any event the 10 via locations allow you more
control over the selected route. I have never used or needed more than 2
via locations but I hope 10 will cover anyone's needs. I can alter it for more
if necessary just let me know. As from V3.0 a requester has been inserted
and you can now decide to tell the program the list of locations from the
start to end location. When you select this option, the following events occur;
1) A request is made for a start location.
2) A request is made for an end location.
3) Up to 10 requests are made for via locations and any cancelled request
aborts any further requests.
4) A requester asks if you want to do it manually or automatically.
5a) AUTOMATIC
You now sit and wait for the route to be found. It's progress can be
monitored and from V3.0 it can be aborted. In version 2.01 I have speeded
up the code and have added a requester that will allow you to reduce the
screen output. The effect of this is to speed up the code by about 3 times.
What was a 15 min. search now takes 5 min. with the screen output turned
off. It still however gives you some indication of what is happening.
5b) MANUAL
A new window will pop up and show you the start location and either the
end location or the first via location. The window will keep popping up until
all the via locations are done. The window will go away on it's own when
you find the end location but if you go wrong you can press the abort
button (that is a separate window and May be hidden) but you loose all the
work up to that point.
In the centre of the window is the location you are currently 'at' above and
below are the locations in the various directions. This will mostly only be two
unless your at a junction. Decide the correct direction to travel and only then
press the appropriate direction button. This will cause the window to update
and now show this new location as the location you are 'at' and the whole
process repeats until you reach the end location. Whilst this May be a fair
amount of work for a long trip, it will probably be quicker than the
automatic system that searches every possible route and or direction.
PRINT - (A)P
Now to the interesting bit. Print, outputs the details of your 'trip' to the
screen and/or printer. The output firstly prints out the settings; pick-up
time; start time; stop time; lunch length; lock time; speed. Now, starting 30
mins. from boat pick-up time the program calculates how long to get to the
next location on your route. If the location is a lock, this time is also
added to the time to travel between locations. This process is repeated for
the next location and so on until the end location is reached. (You will of
course normally be starting and ending at the same location.) If it is lunch
time and you are at a 'preferred stop' the program will add in the time for
lunch and indicate the time to cast off. Similarly, if the location is a
preferred stop and it is your night stop time or later you will be told that
this is your night stop and the morning start time will be used as cast off
time the next day. If, within certain limits, no suitable 'preferred stop' is
found for lunch or night time a forced stop will be made at any location. If a
location is indicated as a 'stop over' then time is allowed at that location
for the time stated in the setting and cast off time is indicated. 'Stop over'
locations once visited are flagged and not stopped at again if you travel past
or through a second time. You will find that you will want to print this to
screen, inspect the stopping places and the time taken. Then 'tweak' the
parameters, reprint and repeat until everything is just right. To help with
this, from V3.0 the print out to screen is put into a lister so you can scroll
back and forward inspecting the route. Finally, commit it to paper to take with
you. At this point I must admit to the poor printing facilities provided within
Blitz2. The printing is done to the simple default workbench printer file PRT:
It is possible from Blitz2 to call the system libraries and I may improve
printer output later if I get enough requests. Ensure your window is wide
enough to see all the information because stops are added to the right of the
text.
ABOUT
Fairly simply a copyright notice and registration details.
ABOUT MUI
Same again for MUI but a bit more detail
MUI PREFS
You should know and have set the MUI prefs as you already use it but
calling it from the program allows you to adjust the prefs for just this
program.
QUIT - (A)Q
No surprises here. The program will quit out warning you if you have an
unsaved map or route in memory.
EDIT MENU
=========
EXTEND MAP - (A)M
This is used to start a new map or to extend a previously loaded map.
Please note that this will not allow you to add locations into an existing
map, only extend it, (That is add to the edge). On selection a requester will
open for you to select the point from which the map is to be extended. If it
is a new map you will not get the requester and the extend map window
will open at location one.
The extend map window at first looks complicated but it is very simple. A
brief description will help. First, the information. At the top of the window
is the location number. You have no control of this number that is used
internally and allocated by the system as needed. If you have two or more
locations with the same name only the one with the lowest location number
is found in a search so beware! At the bottom of the window the locations
in the four directions adjacent to this location are shown to help you move
about the map. Note that with limited space for the name it may be
truncated. Now to the business part of the window. Near the top is a string
requester for the location name. Any alpha-numeric string may be used but
avoid using the name of another location. If no name is entered the system
will allocate a default name. Under the name are two check mark buttons.
One for preferred stops and one for locks. A preferred stop will be used as a
stopping point for lunch or night time whenever possible. A non-preferred
stop will only be used if unavoidable. So select the location as a preferred
stop if it's near a pub or shops or in a town or village worth seeing. The
'lock' button is fairly obvious in use but for the system to be accurate every
lock must be included with this button set so that travelling times can be
calculated. You will see below that a distance must be set between every
location but sometimes locks are so close together that they effectively have
no distance between them. To allow the system to cope, just show one tenth
of a mile between each lock regardless of how close they are. If they are
more than this then show the correct distance. For example, Foxton is two
sets of 5 locks in a staircase. This would be shown as 10 locations spanning
a total of one mile. In truth, the distance is probably less that a quarter
mile but if you've been up or down Foxton locks you will know the extra
time created by the distance is needed anyway. In the centre-ish are four
direction buttons. Once you have entered the name of the location and set
the 'lock' and 'stop' buttons according to need it is time to move on to the
next location. As the map is not a detailed record of the canal system only
four directions are used so pick the most appropriate. It actual fact, the
direction has no relevance whatsoever. It is used simply to help in use and
creation of the map. If you click on a direction that already has a location
in that direction then you will be moved to that location. If however you click
in an empty direction a small requester will appear to ask you the distance
to the new location. Enter the distance in miles (or more appropriately parts
of a mile) to the next location and press return. Note that the minimum
distance is 0.1 miles and the maximum is 5 miles. A distance of nil is no
connection and can not be accepted as an entry. After a valid distance has
been entered a new location is created and the proses is repeated. You have
two ways to end the map entry. 'Dump and exit' or 'save and exit'. It
should be obvious that dump will delete the current entry and it's
connections before exiting and save will exit and keep the current location.
Dump will remove the location even if it had previously been saved. This is
the only way to scrap a location from the map. If you are looking for a
'delete location' menu item then you are out of luck. Select 'extend map',
pick the location to scrap and then do a 'dump and exit'. You will have to
confirm your selection in this case. The system will try to re-connect the
adjoining locations if at all possible but if it is unable to do so a warning
will be given and you will have to re-select 'extend map' and connect up
the gap. That brings us nicely to the last button in the window 'Connect To'.
This is used in place of a direction button when you want to connect this
location to a location already existing in the map. For example to close up a
circular route. On clicking this button you will be asked which direction to
connect in and the distance to the location and then the location to connect
to. You must select a valid direction. i.e. If you select north then this
location must have no existing north connection and the new location must
have no existing south connection. The maps provided with the program
will help you to see how all this works.
LOCATION NAME - (A)E
Simple option to select a location and change it's name. As stated above,
avoid using the same location name for more than one location. Should you
give it no name at all, a default name will be created.
LOCATION DISTANCE - (A)D
Same again, select a location and change the distance to another location.
INSERT LOCATION - (A)I
Again not very complicated. First you are asked for a location to insert next
to. Then the direction in which it is to be inserted. Finally, the name for
the new location. The new location is inserted mid-way between the two old
locations. Use Edit>Location distance if you need to change the distances
and Edit>Extend map to make it a lock or preferred stop.
SET STOPS - (A)V
There are places along your trip that you may want to stop at for a look
around. By setting the location as a stop the system will stop at this location
regardless of the time of day for the period given. You select each location
required and are asked for the length of time (in minutes) to stay there. If a
selected location is arrived at during lunch, the stop time will be added to
the lunch time (Is this a bug or a feature?). The stops are stored in the map
but are not saved as part of the map. The stops are saved as part of the
route. If you start a new route the stops will remain in the map and be used
accordingly. It may be necessary therefore to delete the stops when a new
route is made on an existing map. The stop window will allow you to amend
or delete them.
In Version 2.01+ the location will only be `stopped at' the first time you
pass through it. If you pass through the same location later, it will not
produce a stop.
DEFAULTS MENU
=============
All the defaults are saved as part of the route. All the defaults except two
use the time requester that is a window with 2 sliders in it to represent a
24hr. clock.
PICK UP TIME - (A)T
A time requester will appear for you to set the time you will pick up the
boat. Your trip will start 30mins. after this time.
MORNING START TIME - (A)B
This is the time used for casting off each morning.
EVENING STOP TIME - (A)F
If a preferred stop is found after this time it is used as the night stop
location. If a preferred stop is not found 30mins. beyond this time the next
location is used as the night stop regardless.
LENGTH OF LUNCH - (A)G
Simply the length of lunch time required. If you do not intend to stop for
lunch set this to zero.
SPEED ON WATER - (A)W
This simple requester allows setting your speed along open canal up and
down. I find that 2.5 m.p.h. is a good average. On canals with few locks the
average goes up and with many locks or difficult flows it can come down.
TIME TO DO LOCK - (A)U
Again simply the time taken to do a lock. Many factors affect the time to
work up or down a lock. Size (physical and quantity) of the crew, size of
lock and rate of fill/empty, amount of other boats using the lock etc. I tend
to use 10 mins. per lock. On big flights like Hatton you often share the
work and can pass other boats without trouble. On smaller flights you have
quicker time for emptying and filling and less hold ups. I have been up to
an hour out it the time to do a flight of locks due to waiting but you can
make it up without too much trouble. If you have a crew of one + captain
then use longer lock times but others wise 10 to 12 minutes shouldn't be
far out. Keeping a log of your trips will help to indicate your average times.
START DAY > SAT. - (A)1
.........
FRI. - (A)7
I'll let you guess what this does.
Well that's it. I hope the above details are informative and the program is
useful. I couldn't take the Guides on holiday without it, particularly as we
have to arrive at change over points within an hour of the time given to the
parents. Arriving early is O.K. but being late makes them anxious.
FEB. 1995
Version 2.01 - Updated 8/6/96 with speed and `set stop' enhancements.
Version 2.1 - JULY 1997 - Made windows font sensitive.
Version 3.0 - AUGUST 1998 - Made Program MUI Dependant. Improved a
few of the sub routines in doing so. Added Abort button to Calculation.
Added Manual entry of route.
Version 3.1 - FEBRUARY 1999 - Fixed bug and improved automatic search
algorithm. Also fixed bug in Route Load that caused 'stops' not to be loaded.
Added option to print to file.
STEVE TURNER
21 OXFORD CLOSE
WASHINGBOROUGH
LN4 1DT.
Bye!
------------------------------------------------------------------------
MUI - MagicUserInterface
(c) Copyright 1992-97, Stefan Stuntz
------------------------------------------------------------------------
MUI is an object oriented system to create and maintain graphical user
interfaces. From a programmers point of view, using MUI saves a lot of
time and makes life much easier. Thinking about complicated terms like
window resizing or font sensitivity is simply not necessary.
On the other hand, users of MUI based applications have the ability to
customize nearly every pixel of a programs interface according to their
personal taste.
------------------------------------------------------------------------
Blitz Basic is a cross between a standard basic language and 'C'.
I strongly recommend anyone with programming experience to have a look at it.
Blitz is a fast compiled language with low level access.
Blitz is copyright 1993 by Acid Software, a division of Armstrong
Communications Limited New Zealand and was developed by Mark Sibly.
Acid Fax= 64-9-358-1658 \
}- Now not Valid ?
UK Phone/Fax= 0171 482 4066 /